package org.kessy.common.model.meta;

import java.io.Serializable;
import java.util.Date;

/***
 * 
 * @author leo.liu
 * parent class of All Meta Class
 */
abstract public class MBase implements Serializable{

    /**
     * 
     */
    private static final long serialVersionUID = -5207175782252171469L;
    
    public final static byte PERSISTTYPE_ADD = 1;
    public final static byte PERSISTTYPE_UPDATE = 2;
    public final static byte PERSISTTYPE_DELETE = 3;
    public final static byte PERSISTTYPE_NOCHANGE = 4;
    
    private Long id;        // the unique identity in DB
    private String oid;     // the unique identity in memory
    private Long version;   // used to version control
    private Date createDate;
    private Date lastUpdateDate;
    private byte persistType;       // should be add/update/delete/nochange
    
    public Long getId() {
        return id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }
    
    public String getOid() {
        return oid;
    }
    
    public void setOid(String oid) {
        this.oid = oid;
    }
    
    public Long getVersion() {
        return version;
    }
    
    public void setVersion(Long version) {
        this.version = version;
    }
    
    public Date getCreateDate() {
        return createDate;
    }
    
    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }
    
    public Date getLastUpdateDate() {
        return lastUpdateDate;
    }
    
    public void setLastUpdateDate(Date lastUpdateDate) {
        this.lastUpdateDate = lastUpdateDate;
    }
    
    public byte getPersistType() {
        return persistType;
    }
    
    public void setPersistType(byte persistType) {
        this.persistType = persistType;
    }
    
    public void copyShallow(MBase mBase){
        this.id = mBase.getId();
        this.oid = mBase.getOid();
        this.persistType = mBase.getPersistType();
        this.version = mBase.getVersion();
        this.createDate = mBase.getCreateDate();
        this.lastUpdateDate = mBase.getLastUpdateDate();
    }
}
